package cn.feizhu.aimarket.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.feizhu.aimarket.model.domain.Book;
import cn.feizhu.aimarket.service.BookService;
import cn.feizhu.aimarket.mapper.BookMapper;
import org.springframework.stereotype.Service;

/**
* @author wsdsb
* @description 针对表【book】的数据库操作Service实现
* @createDate 2025-10-12 13:03:42
*/
@Service
public class BookServiceImpl extends ServiceImpl<BookMapper, Book>
    implements BookService{

    @Override
    public void updateBookDownloadCount(String filePath) {
        QueryWrapper<Book> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("uri", filePath);
        Book book = this.getOne(queryWrapper);
        if (book != null) {
            book.setDownloads(book.getDownloads() + 1);
            this.updateById(book);
        }
    }
}
